﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Hotnet.Entity.VideoCategory>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	视频分类管理
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<h2>
		视频分类管理</h2>
	<table width="100%" class="ma list">
		<tr>
			<th width="50px;">
				分类ID
			</th>
			<th>
				分类名称
			</th>
			<th>
				分类的tag
			</th>
			<th>
				排序
			</th>
			<th>
				操作
			</th>
		</tr>
		<% foreach (var item in Model)
	 { %>
		<tr>
			<td style=" text-align:center">
				<%= Html.Encode(item.CategoryID) %>
			</td>
			<td>
				<%= Html.Encode(item.Name) %>
			</td>
			<td>
				<%=Html.Encode(item.Tag) %>
			</td>
			<td>
				<%= Html.Encode(item.OrderNo) %>
			</td>
			<td style=" text-align:center">
				<a href="javascript:void(0);" onclick="editCategory(<%=item.CategoryID %>, '<%=item.Name%>','<%=item.OrderNo %>','<%=item.Tag %>')">编辑</a> |
				<a href="javascript:void(0);" onclick="deleteCategory('<%=item.CategoryID %>')">删除</a> 
			</td>
		</tr>
		<% } %>
	</table>

	<p>
		<a href="javascript:viod(0);" onclick="newCategory();" class="b1 p5 dbk blik fl">新增视频分类</a>
	</p>
	<div id="createWindow" style="display:none;">
		<%using (Html.BeginForm("Create", "AdminVideoCategory", FormMethod.Post, new { id="formMutiple"}))
	{%>
		<input type="hidden" name="categoryID" id="categoryID" />
		<div class="tac ma">
			<span class="mr3">分类名称:</span>
			<input type="text" name="name" id="name" />
		</div>
		<div class="tac ma">
			<span class="mr3">分类排序:</span>
			<input type="text" name="orderNo" id="orderNo" />
		</div>
		<div class="tac ma">
			<span class="mr3">分类的Tag:</span>
			<input type="text" name="tag" id="tag" />
		</div>
		<div style="text-align:center; margin-top:5px;">
			<input type="submit" value="确定" class="ml3 boxy-button"/>
			<input type="button" value="关闭" class="ml3 boxy-button" onclick="closeWindow();" />
		</div>
		<% } %>
	</div>
	
	<div>
		<%Html.BeginForm("Delete", "AdminVideoCategory", FormMethod.Post, new { id="formDelete"}); %>
			<input type="hidden" id="hiddenCategoryID" name="id" />
		<%Html.EndForm(); %>
	
	</div>
	
	<script type="text/javascript">
		var boxy;
		function showWindow() {
			if (boxy == null)
				boxy = new Boxy($('#createWindow'), { modal: false, title: '新增视频分类', closeText: '[×]', draggable: true }).resize(310, 100);
			else
				boxy.show();
		}
		function closeWindow() {
			boxy.hide();
		}

		function newCategory() {
			$("#formMutiple").attr("action", "/AdminVideoCategory/Create");
			$("#name").attr("value", "");
			$("#orderNo").attr("value", "");
			$("#categoryID").attr("value", "");
			$("#tag").attr("value", "");

			showWindow();
			boxy.setTitle("新增视频分类");
		}

		function editCategory(categoryId, name, orderNo,tag) {
			$("#categoryID").attr("value",categoryId);
			$("#name").attr("value", name);
			$("#orderNo").attr("value", orderNo);
			$("#tag").attr("value", tag);
			$("#formMutiple").attr("action", "/AdminVideoCategory/Edit");

			showWindow();
			boxy.setTitle("编辑视频分类");
		}

		function deleteCategory(id) {

			if (!confirm("确定删除此视频分类?"))
				return;
			$("#hiddenCategoryID").attr("value", id);
			$("#formDelete").submit();
		}
	
	</script>
	
	
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
</asp:Content>	
<asp:Content ID="Content4" ContentPlaceHolderID="StyleContent" runat="server">
</asp:Content>
